<?php
App::uses('AppController', 'Controller');
/**
 * IssueStates Controller
 *
 * @property IssueState $IssueState
 */
class IssueStatesController extends AppController {

/**
 * index method
 *
 * @return void
 */
	public function index()
	{
    	$issueStates = $this->IssueState->find('all');
        $this->set(array(
            'issueStates' => $issueStates,
            '_serialize' => array('issueStates')
        ));
	}

/**
 * view method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
	public function view($id = null) {
		$this->IssueState->id = $id;
		if (!$this->IssueState->exists()) {
			throw new NotFoundException(__('Invalid issue state'));
		}
		$this->set('issueState', $this->IssueState->read(null, $id));
	}

/**
 * add method
 *
 * @return void
 */
	public function add() {
		if ($this->request->is('post')) {
			$this->IssueState->create();
			if ($this->IssueState->save($this->request->data)) {
				$this->flash(__('Issuestate saved.'), array('action' => 'index'));
			} else {
			}
		}
	}

/**
 * edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
	public function edit($id = null) {
		$this->IssueState->id = $id;
		if (!$this->IssueState->exists()) {
			throw new NotFoundException(__('Invalid issue state'));
		}
		if ($this->request->is('post') || $this->request->is('put')) {
			if ($this->IssueState->save($this->request->data)) {
				$this->flash(__('The issue state has been saved.'), array('action' => 'index'));
			} else {
			}
		} else {
			$this->request->data = $this->IssueState->read(null, $id);
		}
	}

/**
 * delete method
 *
 * @throws MethodNotAllowedException
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
	public function delete($id = null) {
		if (!$this->request->is('post')) {
			throw new MethodNotAllowedException();
		}
		$this->IssueState->id = $id;
		if (!$this->IssueState->exists()) {
			throw new NotFoundException(__('Invalid issue state'));
		}
		if ($this->IssueState->delete()) {
			$this->flash(__('Issue state deleted'), array('action' => 'index'));
		}
		$this->flash(__('Issue state was not deleted'), array('action' => 'index'));
		$this->redirect(array('action' => 'index'));
	}
}
